//
//  ACMemoryCache.h
//  ACCache_Example
//
//  Created by autohome on 2021/8/7.
//  Copyright © 2021 CaiXiang. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface ACMemoryCache : NSObject

@property (nonatomic) NSUInteger costLimit;
@property (nonatomic) NSUInteger countLimit;

@property (nonatomic) BOOL shouldRemoveAllObjectsOnMemoryWarning;
@property (nonatomic) BOOL shouldRemoveAllObjectsWhenEnteringBackground;

@property(copy,nonatomic) NSString *name;

@property (nullable, copy) void(^didReceiveMemoryWarningBlock)(ACMemoryCache *mc);
@property (nullable, copy) void(^didEnterBackgroundBlock)(ACMemoryCache *mc);

@property (nonatomic,readonly) NSUInteger totalCount;
@property (nonatomic,readonly) NSUInteger totalCost;

+ (instancetype)new NS_UNAVAILABLE;

- (instancetype)init NS_UNAVAILABLE;

- (nullable instancetype)initWithName:(NSString *)name;

- (BOOL)containsObjectForKey:(id)key;
- (nullable id)objectForKey:(nonnull id)key;
- (void)setObject:(nullable id)object forKey:(nonnull id)key;
- (void)setObject:(nullable id)object forKey:(nonnull id)key cost:(NSUInteger)cost;
- (void)removeObjectForKey:(nonnull id)key;
- (void)removeAllObjects;

- (NSArray *)allkeys;
- (NSArray *)allValues;

@end

NS_ASSUME_NONNULL_END
